<template>
  <div class="account-table-wrap">
    <el-table
      :data="tableData"
      style="width: 100%"
      :border="true"
      :fit="true"
      :stripe="true"
      size="mini"
      align="center">
      <el-table-column
      :show-overflow-tooltip="true"
        prop="auxiliary_number"
        label="辅件编号"
        min-width="80"
        align="center">
      </el-table-column>

      <el-table-column
      :show-overflow-tooltip="true"
        prop="auxiliary_name"
        label="辅件名称"
        min-width="90"
        align="center">
      </el-table-column>

      <el-table-column
      :show-overflow-tooltip="true"
        prop="format"
        label="规格/型号"
        min-width="90"
        align="center">
      </el-table-column>

      <el-table-column
        prop="auxiliary_unit"
        label="单位"
        min-width="80"
        align="center">
      </el-table-column>

      <el-table-column
        prop="type"
        label="类型"
        min-width="80"
        align="center">
      </el-table-column>

      <el-table-column
      :show-overflow-tooltip="true"
        prop="orders"
        label="单号"
        min-width="80"
        align="center">
      </el-table-column>

      <el-table-column
        prop="date"
        label="出入库日期"
        min-width="150"
        align="center">
      </el-table-column>

      <el-table-column
        prop="number"
        label="出入库数量"
        min-width="90"
        align="center">
        <template slot-scope="scope">
          <div class="tit-pic">
            <!-- <div class="pic" :class="scope.row.number>0?'a':'b'">{{scope.row.number}}</div> -->
            <div class="pic" :class="scope.row.number>0?'a':scope.row.number<0?'b':''">{{scope.row.number>0?'+'+scope.row.number:scope.row.number }}</div>

          </div>
        </template>
      </el-table-column>

      <el-table-column
        prop="stock"
        label="库存"
        min-width="120"
        align="center">
      </el-table-column>

      <el-table-column label="操作"
      min-width="90"
      align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            plain
            type="primary"
            @click="checkDetail(scope.row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <deleteConfirm v-if="showMask" @closeDelete="closeDelete" @deleteConfirm="deleteConfirm"></deleteConfirm>
  </div>
</template>
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
import { Prop, Emit } from 'vue-property-decorator';
import deleteConfirm from '@/components/deleteConfirm.vue';
import ajaxResquest from '@/api/apiRequest';
@Component({
  components: {
    deleteConfirm
  }
})
export default class AccountListTable extends Vue {
  // tableData: Array<any> = [];
  @Prop({
    type: Array
  })
  tableData!: any[];
  showMask: boolean = false;
  deleteId!: number;
  deleteRes!: ajaxResquest;
  mounted() {
    this.deleteRes = new ajaxResquest('/system/account/delete');
  }
  // @Emit('checkDetail')
  checkDetail(row: any) {
    if (row.type === '入库') {
      this.$to('auxiliaryInCheck', {
        check: true,
        id: row.id
      });
    } else if (row.type === '出库') {
      this.$to('auxiliaryOutCheck', {
        check: true,
        id: row.id
      });
    }
    // console.log(row);
    // this.$to('accountCreate', { edit: true, id: row.id });
  }
  tableDelete(row: any) {
    console.log(row);
    this.deleteId = row.id;
    this.showMask = true;
  }
  closeDelete(row: object) {
    this.showMask = false;
  }
  deleteConfirm() {
    this.deleteRes.getFunction({ user_id: this.deleteId }).then((res:any) => {
      if (res.data.code === 1) {
        this.showMask = false;
        this.getData();
      }
    });
  }
  @Emit('getData')
  getData() {}
}
</script>
<style lang="less">
.a {
  color: #66cccc;
}
.b {
  color: #cc0000;
}
</style>

